package com.itheima.mm.controller;

import com.itheima.mm.dto.CourseDTO;
import com.itheima.mm.dto.IndustryDTO;
import com.itheima.mm.entity.*;
import com.itheima.mm.pojo.Industry;
import com.itheima.mm.service.IndustryService;
import com.itheima.mm.vo.IndustryVO;
import com.itheima.mm.vo.QuestionMMVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description IndustryController
 * @Author kangwei
 * @Date 2024-06-26
 */

@Slf4j
@RequestMapping("/industry")
@RestController
public class IndustryController {
    @Autowired
    private IndustryService industryService;

    @GetMapping("/findListAll.do")
    public Result<List<IndustryVO>> findListAll(){
        log.info("开始执行获取行业方向全部列表接口");
        List<IndustryVO> industryVOList = industryService.findListAll();

        return Result.success(industryVOList);


    }

    @PostMapping("/findListByPage.do")
    public Result<PageResult<IndustryVO>> findListByPage(
            @RequestBody QueryPageBean<IndustryPageQueryParams> queryPageBean){
        log.info("处理试题分页查询请求，请求参数：{}",queryPageBean);

        PageResult<IndustryVO>pageResult = industryService.findListByPage(queryPageBean);

        return Result.success(pageResult);
    };

    @PostMapping("/add.do")
    public Result add(@RequestBody IndustryDTO industryDTO){
        log.info("处理添加方向请求，请求参数：{}",industryDTO.toString());
        industryService.add(industryDTO);

        //返回数据
        return Result.success();

    };

    @GetMapping("/delete.do")
    public Result delete(Integer id){
        log.info("开始执行方向标签删除接口：{}",id);

        //调用业务
        industryService.delete(id);

        //返回数据
        return Result.success(null,"方向删除成功");
    }



}
